/**
 * CMOSTEK Sub-G 射频芯片 SPI 接口驱动
 * Copyright (c) 2021 深圳市智辰科技有限公司
 * All rights reserved.
 */

#ifndef _DRIVER_CMTSPI3_H_
#define _DRIVER_CMTSPI3_H_

#include "nonos.h"


// CMOSTEK Sub-G 射频芯片 SPI 接口驱动数据结构
typedef struct {
	// GPIO 驱动函数
	FUNC_GPIO_Out csb;
	FUNC_GPIO_Out fcsb;
	FUNC_GPIO_Out sclk;
	FUNC_GPIO_Out dout;
	FUNC_GPIO_ReadIn din;
	FUNC_GPIO_ReadIn gpio;
} driver_cmtspi3_t;

/**
 * @brief 驱动初始化
 */
void cmtspi3_init(driver_cmtspi3_t *dev);

void cmtspi3_tx(driver_cmtspi3_t *dev, uint8_t ch);
uint8_t cmtspi3_rx(driver_cmtspi3_t *dev);
void cmtspi3_write_reg(driver_cmtspi3_t *dev, uint8_t addr, uint8_t ch);
uint8_t cmtspi3_read_reg(driver_cmtspi3_t *dev, uint8_t addr);
void cmtspi3_write_fifo(driver_cmtspi3_t *dev, const uint8_t* buf, uint16_t len);
void cmtspi3_read_fifo(driver_cmtspi3_t *dev, uint8_t* buf, uint16_t len);

void cmtspi3_test(driver_cmtspi3_t *dev);


#endif // _DRIVER_CMTSPI3_H_
